import json


def read_data(path, mode='r', encoding='utf8'):
    try:
        with open(path, mode=mode, encoding=encoding) as fp:
            data = json.load(fp)
            return data
    except FileNotFoundError:
        return False


def save_data(data: dict, path, mode='w', encoding='utf8'):
    try:
        with open(path, mode=mode, encoding=encoding) as fp:
            json.dump(data, fp)
            fp.flush()
            return False
    except Exception as e:
        return f"意料之外的错误！错误信息{e}"
